package help;

import java.util.List;

import dao.CommentDAO;
import dao.ThemeDAO;
import dao.UserDAO;
import entity.Article;
import entity.Comment;
import entity.Content;
import entity.Theme;

public class ShowArticle {

	private Article article;
	private Content content;
	private List<Comment> comments;
	private Theme theme;
	private ThemeDAO themeDAO = ThemeDAO.getInstance();
	private CommentDAO commentDAO = CommentDAO.getInstance();
	private UserDAO userDAO = UserDAO.getInstance();
	int num;
	public ShowArticle() {
		// TODO Auto-generated constructor stub
	}
	/**
	 * @param article
	 * @param content
	 * @param comments
	 * @param theme
	 */
	public ShowArticle(Article article, Content content, List<Comment> comments) {
		super();
		this.article = article;
		this.content = content;
		this.comments = comments;
		
		this.num=comments.size();
		for(int i=0;i<comments.size();i++){
			Comment comment = comments.get(i);
			int user_id=commentDAO.getByID(comment.getComment_id()).getUser_id();
			comment.setUser_name(userDAO.get(user_id).getUser_name());
		}
	}
	
	/**
	 * @param article
	 * @param content
	 */
	public ShowArticle(Article article, Content content) {
		super();
		this.article = article;
		this.content = content;
		this.theme = themeDAO.get(article.getTheme_id());
	}
	/**
	 * @return the article
	 */
	public Article getArticle() {
		return article;
	}
	/**
	 * @param article the article to set
	 */
	public void setArticle(Article article) {
		this.article = article;
	}
	/**
	 * @return the content
	 */
	public Content getContent() {
		return content;
	}
	/**
	 * @param content the content to set
	 */
	public void setContent(Content content) {
		this.content = content;
	}
	/**
	 * @return the comments
	 */
	public List<Comment> getComments() {
		return comments;
	}
	/**
	 * @param comments the comments to set
	 */
	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}
	/**
	 * @return the theme
	 */
	public Theme getTheme() {
		return theme;
	}
	/**
	 * @param theme the theme to set
	 */
	public void setTheme(Theme theme) {
		this.theme = theme;
	}
	/**
	 * @return the themeDAO
	 */
	public ThemeDAO getThemeDAO() {
		return themeDAO;
	}
	/**
	 * @param themeDAO the themeDAO to set
	 */
	public void setThemeDAO(ThemeDAO themeDAO) {
		this.themeDAO = themeDAO;
	}
	/**
	 * @return the num
	 */
	public int getNum() {
		return num;
	}
	/**
	 * @param num the num to set
	 */
	public void setNum(int num) {
		this.num = num;
	}

	

}
